import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2023-04-23
 * Time: 15:48
 */
public class QuickSort {
    public static void main1(String[] args) {
        int[] arr = {3, 1, 3, 1, 3};
        quickSort(arr, 0, arr.length - 1);
        for (int i : arr) {
            System.out.print(i + " ");
        }
    }

    public static void quickSort(int[] arr, int start, int end) {
        if (start >= end) {
            return;
        }
        int left = start;
        int right = end;
        int pivotIndex = (left + right) / 2;
        int pivotValue = arr[pivotIndex];
        while (left <= right) {
            while (arr[left] < pivotValue) {
                left++;
            }
            while (arr[right] > pivotValue) {
                right--;
            }
            if (left <= right) {
                swap(arr, left, right);
                left++;
                right--;
            }
        }
        quickSort(arr, start, right);
        quickSort(arr, left, end);
    }

    public static void swap(int[] arr, int i, int j) {
        int temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }

    public static void main(String[] args) {
        Random random = new Random();
        int right = 3;
        int left = 2;
        int pivotIndex = random.nextInt(right - left + 1) - left;
        while(true) {
            System.out.println(pivotIndex);
        }
    }
}
